package com.leyou.order.config;

import com.leyou.utils.IdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: Rose
 * @Date: 2021/4/13 11:43
 * @description ${description}
 * @version: 1.0.0
 */
@EnableConfigurationProperties(value = {IdWorkerProperties.class})
@Configuration
public class IdWorkerConfig {

    @Autowired
    private IdWorkerProperties idWorkerProperties;


    @Bean
    public IdWorker idWorker() {
        return new IdWorker(idWorkerProperties.getWorkerId(), idWorkerProperties.getDataCenterId());
    }
}
